Trò chơi đua xe động vật trong UNITY Engine
114.684 lượt xem;
- Cloud.cs
- AnimalRacing /
- Scripts /
- Assets /
- project /
1 using UnityEngine;
2 using System.Collections;
3
4 public class Cloud : MonoBehaviour {
5
6 private Vector3 speed;
7
8 public void Start()
9 {
10 speed = new Vector3(-1, 0, 0);
11 }
12
13 public void Update () {
14 transform.localPosition += speed * Time.deltaTime;
15 if (transform.localPosition.x <= -6)
16 transform.localPosition = new Vector3(8, Random.Range(-2, 2), transform.localPosition.z);
17 }
18 }
2 using System.Collections;
3
4 public class Cloud : MonoBehaviour {
5
6 private Vector3 speed;
7
8 public void Start()
9 {
10 speed = new Vector3(-1, 0, 0);
11 }
12
13 public void Update () {
14 transform.localPosition += speed * Time.deltaTime;
15 if (transform.localPosition.x <= -6)
16 transform.localPosition = new Vector3(8, Random.Range(-2, 2), transform.localPosition.z);
17 }
18 }